<template>
  <div id="jkrz">
    <van-nav-bar title="新增复康日志" left-arrow left-text="返回" @click-left="onClickLeft" fixed placeholder>
     
    </van-nav-bar>
    <div class="harder">
      <van-row type="flex" justify="space-between" align="center">
        <van-col span="15">
          <img src="@/assets/images/jkrzimg.png" alt=""/>
          <span>{{ getnewDate() }}</span>
        </van-col>
        <van-col span="8">
          <span class="all" @click="$router.push(`/HealthLogList/${hzid}`)"
          >全部复康日志<van-icon name="arrow"
          /></span>
        </van-col>
      </van-row>
      <van-row type="flex" justify="space-between" align="center">
        <van-col span="15"></van-col>
        <van-col span="8">
          <div class="tx" v-show="is_have_weiwancheng">
            <img src="@/assets/images/jkrztx.png" alt=""/><span
          >有未完成日志</span
          >
          </div>
        </van-col>
      </van-row>
    </div>
    <div class="main">
      <van-row
        type="flex"
        justify="space-between"
        align="center"
        @click="BodyAndExercise"
      >
        <van-col span="2">
          <img src="@/assets/images/stjyd.png" alt=""/>
        </van-col>
        <van-col span="10">
          <span class="title">身体及运动</span>
        </van-col>
        <van-col span="6">
          <span v-if="list.is_shitiyundong == 0 || list.is_shitiyundong == 1">
            <span v-if="list.is_shitiyundong == 0"
            ><img src="@/assets/images/dot.png"/>去完成<van-icon name="arrow"
            /></span>
            <span v-else-if="list.is_shitiyundong == 1"
            ><img src="@/assets/images/Checkmark.png"/>已完成<van-icon
              name="arrow"
            /></span>
          </span>
          <span v-else-if="next.length">
            <span v-if="next[0].day_num"
            >{{ next[0].day_num }}天后<van-icon name="arrow"
            /></span>
          </span>
          <span v-else>可填写<van-icon name="arrow"/></span>
        </van-col>
      </van-row>
      <van-row type="flex" justify="space-between" align="center" @click="food">
        <van-col span="2">
          <img src="@/assets/images/ysyy.png" alt=""/>
        </van-col>
        <van-col span="10">
          <span class="title">饮食营养</span>
          <div class="info">
            <van-icon name="aim"/>
            今日膳食评分：<span class="numInfo">{{ list.pingfen ? list.pingfen : 1 }}</span>分
          </div>
        </van-col>
        <van-col span="6">
          <span
            v-if="list.is_yinshiyingyang == 0 || list.is_yinshiyingyang == 1"
          >
            <span v-if="list.is_yinshiyingyang == 0"
            ><img src="@/assets/images/dot.png"/>去完成<van-icon name="arrow"
            /></span>
            <span v-else-if="list.is_yinshiyingyang == 1"
            ><img src="@/assets/images/Checkmark.png"/>已完成<van-icon
              name="arrow"
            /></span>
          </span>
          <span v-else-if="next.length">
            <span v-if="next[0].day_num"
            >{{ next[0].day_num }}天后<van-icon name="arrow"
            /></span>
          </span>
          <span v-else>可填写<van-icon name="arrow"/></span>
        </van-col>
      </van-row>
      <van-row
        type="flex"
        justify="space-between"
        align="center"
        @click="Physical"
      >
        <van-col span="2">
          <img src="@/assets/images/stzz.png" alt=""/>
        </van-col>
        <van-col span="10">
          <span class="title">
            身体症状
          </span>
        </van-col>
        <van-col span="6">
          <span
            v-if="
              list.is_shentizhengzhuang == 0 || list.is_shentizhengzhuang == 1
            "
          >
            <span v-if="list.is_shentizhengzhuang == 0"
            ><img src="@/assets/images/dot.png"/>去完成<van-icon name="arrow"
            /></span>
            <span v-else-if="list.is_shentizhengzhuang == 1"
            ><img src="@/assets/images/Checkmark.png"/>已完成<van-icon
              name="arrow"
            /></span>
          </span>
          <span v-else-if="next.length">
            <span v-if="next[0].day_num"
            >{{ next[0].day_num }}天后<van-icon name="arrow"
            /></span>
          </span>
          <span v-else>可填写<van-icon name="arrow"/></span>
        </van-col>
      </van-row>
      <van-row type="flex" justify="space-between" align="center" @click="bool">
        <van-col span="2">
          <img src="@/assets/images/xyzb.png" alt=""/>
        </van-col>
        <van-col span="11">
          <span class="title">
            血液指标
          </span>
          <div class="info">
            如有最新检测，请及时上传
          </div>
        </van-col>
        <van-col span="6">
          <span v-if="list.is_xueyezhibiao == 0 || list.is_xueyezhibiao == 1">
            <span v-if="list.is_xueyezhibiao == 0"
            ><img src="@/assets/images/dot.png"/>去完成<van-icon name="arrow"
            /></span>
            <span v-else-if="list.is_xueyezhibiao == 1"
            ><img src="@/assets/images/Checkmark.png"/>待完成<van-icon
              name="arrow"
            /></span>
          </span>
          <span v-else-if="next.length">
            <span v-if="next[0].day_num"
            >{{ next[0].day_num }}天后<van-icon name="arrow"
            /></span>
          </span>
          <span v-else>可填写<van-icon name="arrow"/></span>
        </van-col>
      </van-row>
      <van-row
        type="flex"
        justify="space-between"
        align="center"
        @click="DrugUse"
      >
        <van-col span="2">
          <img src="@/assets/images/yyqk.png" alt=""/>
        </van-col>
        <van-col span="10">
          <span class="title">
            用药情况
          </span>
        </van-col>
        <van-col span="6">
          <span
            v-if="
              list.is_yongyaoqingkuang == 0 || list.is_yongyaoqingkuang == 1
            "
          >
            <span v-if="list.is_yongyaoqingkuang == 0"
            ><img src="@/assets/images/dot.png"/>去完成<van-icon name="arrow"
            /></span>
            <span v-else-if="list.is_yongyaoqingkuang == 1"
            ><img src="@/assets/images/Checkmark.png"/>已完成<van-icon
              name="arrow"
            /></span>
          </span>
          <span v-else-if="next.length">
            <span v-if="next[0].day_num"
            >{{ next[0].day_num }}天后<van-icon name="arrow"
            /></span>
          </span>
          <span v-else>可填写<van-icon name="arrow"/></span>
        </van-col>
      </van-row>
    </div>
    <div class="footer">
      <van-row
        type="flex"
        justify="space-between"
        align="center"
        @click="$router.push(`/line/${hzid}`)"
      >
        <van-col span="2">
          <img src="@/assets/images/jkqx.png" alt=""/>
        </van-col>
        <van-col span="10">
          <div class="title">
            复康日志曲线
          </div>
        </van-col>
        <van-col span="6"
        ><span>更多<van-icon name="arrow"/></span
        ></van-col>
      </van-row>
    </div>
  </div>
</template>

<script>
// getHealthLog
import {getHealthLog} from "@/apis/journal";
import { addHealthLog } from "@/apis/journal";
export default {
  data() {
    return {
      hzid:null,
      rzid:'',
      is_have_weiwancheng: "",
      next: [],
      list: [],
      log_date:null
    };
  },
  methods: {
    getnewDate() {
      var myDate = new Date();
      var time = myDate
        .toLocaleDateString()
        .split("/")
        .join("-");
      return time;
    },
    onClickLeft() {
      this.$router.go(-1); //返回上一层
    },
    healthLog() {
      getHealthLog({pid:this.hzid})
        .then(res => {
          console.log(res);
          this.is_have_weiwancheng = res.data.is_have_weiwancheng;
          this.next = res.data.next;
          this.list = res.data.data;
          if (res.data.data.id) {
            let expire = new Date(
              new Date().setDate(new Date().getDate() + 1)
            ).setHours(0, 0, 0, 0);
            this.localStorageSet("id", res.data.data.id, expire);
            let log_date = res.data.data.log_date
            this.log_date = log_date.split(" ")[0]
         }
        })
        .catch(err => {
          if(err.msg){
            this.$toast(err.msg);
          }else{
            this.$toast("网络错误"); 
          }
        });
    },
    Physical() {
     
      // if (!this.next.day_num) {
      this.$router.push(`/Physical/${this.hzid}`);
      // }
    },
    BodyAndExercise() {
      // if (!this.next.day_num) {
      this.$router.push(`/BodyAndExercise/${this.hzid}`);
      // }
    },
    food() {
      // if (!this.next.day_num) {
      this.$router.push(`/food/${this.hzid}`);
      // }
    },
    bool() {
      // if (!this.next.day_num) {
      this.$router.push(`/bool/${this.hzid}`);
      // }
    },
    DrugUse() {
      // if (!this.next.day_num) {
      this.$router.push(`/DrugUse/${this.hzid}`);
      // }
    }
  },
  mounted() {
    this.healthLog();  
  },
  created() {
    this.hzid = parseInt(this.$route.params.id)
    let idDet = localStorage.getItem("id")
    this.rzid =  JSON.parse(idDet)
    console.log(this.rzid)
  }
};
</script>

<style lang="less">
#jkrz {
  background-color: #fff;
  padding-bottom: 60px;
  text-align: left;
  .van-icon,.van-nav-bar__text {
    color: #404040;
  }
  .harder {
    padding: 47px 0;
    background: rgba(78, 138, 244, 1);
    position: relative;
    text-align: center;

    img {
      width: 32px;
      height: 32px;
      margin-right: 14px;
      vertical-align: middle;
    }

    span {
      vertical-align: middle;
      font-size: 25px;
      color: #fff;
      font-weight: 500;

      &.all {
        font-size: 12px;

        i {
          vertical-align: text-bottom;
        }
      }
    }

    .tx {
      width: 100px;
      height: 17px;
      margin: auto;
      line-height: 17px;
      background: rgba(58, 116, 222, 1);
      border-radius: 8px;

      img {
        width: 9px;
        height: 10px;
        vertical-align: middle;
        margin-right: 4px;
      }

      span {
        font-size: 10px;
        vertical-align: middle;
      }
    }
  }
  .main,
  .footer {
    margin: 15px 9px;

    .van-row {
      padding: 15px 14px;
      border-bottom: 1px solid rgba(210, 210, 210, 1);

      .info {
        font-size: 12px;
        font-weight: 400;
        color: rgba(104, 104, 104, 1);

        .numInfo {
          color: red;
          font-size: 14px;
        }
      }


      .van-col {
        img {
          width: 47px;
        }

        &:last-child {
          text-align: right;

          span {
            font-size: 12px;
            color: rgba(155, 155, 155, 1);

            img {
              width: 6px;
              margin-right: 4px;
            }

            i {
              margin-left: 3px;
              vertical-align: text-bottom;
            }
          }
        }
      }
    }
  }
  .footer{
    .van-row{
      border: none;
    }
  }
}
</style>
